<!DOCTYPE html>
<html lang="en">

<head>
   <meta charset="UTF-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <script src="../.utils/flexible.js"></script>
   <link rel="stylesheet" href="../css/moneyctrl.css">
   <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
   <script src="../js/moneyctrl.js"></script>
   <title>Document</title>
</head>

<body>
   <div id="container">
      <div class="header">
         <div><a href="../index.html">
               < </a>
         </div>
         <div>省钱控-最新优惠</div>
         <div class="imge"><img src="../assets/iconFonts/header_app.png" alt=""></div>
      </div>
      <div class="middle">
         <ul id="list">
         </ul>
         <div class="change">
            <div>
               <button class="btn1">上一页</button>
            </div>
            <div>
               <select name="" id="">
               </select>
            </div>
            <div>
               <button class="btn2">下一页</button>
            </div>
         </div>
      </div>
      <div id="bottom">
         <div class="more"><a href="">更多优惠信息>></a></div>
         <div class="logo3">
            <span>品牌排行</span>
            <div class="circle">></div>
         </div>
         <div class="footer">
            <div class="left">登入</div>
            <div class="middle">注册</div>
            <div class="right">返回顶部</div>
         </div>
         <div class="text">
            <p>手机App下载慢慢买手机版--掌上比价平台</p>
            <p>m.manmanbuy.com</p>
         </div>
      </div>
   </div>
</body>

</html>
<script>
   $(function () {
      var currentPage = 0;
      let select = document.querySelector('select')
      select.addEventListener('change', changeSelect)
      function changeSelect(e) {
          currentPage = select.selectedIndex
         initData()
      }
      let list = document.getElementById('list');
      function initData() {
         $.ajax({
            type: 'get',
            url: `http://chst.vip:1234/api/getmoneyctrl?pageid=${currentPage}`
         }).then(res => {
            list.innerHTML = '';
            var arr = res.result;
            arr.forEach(item => {
               let li = document.createElement('li')
               li.innerHTML = `<div class="left">${item.productImg2}</div>
               <div class="right">
                  <h4>${item.productName}</h4>
                  <div class="rightText">
                     <div>${item.productFrom} | ${item.productTime}</div>
                     <div>
                        <span></span>
                        <div>${item.productComCount}</div>
                     </div>
                  </div>
               </div>`
               list.append(li)
            })

            var arr = res.totalCount;


            for (i = 0; i < Math.ceil(arr / 10) ; i++) {
               let option = document.createElement('option')
               option.innerHTML = `<option value=${i}>${i + 1}/${Math.ceil(arr / 10)}</option>`
               select.append(option)
            }
       })
      }
      initData()
   })

</script>